package com.thtf.homework.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import com.thtf.homework.model.DataCat;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface DataCatMapper {

    @Select("""
            SELECT * FROM "LIWEIJIE"."T_SJYGL_SJML"  WHERE "SFSC" = 'F';
            """)
    List<DataCat> queryDataCat();


    @Insert("""
             INSERT INTO "LIWEIJIE"."T_SJYGL_SJML" ("MLBH", "MLMC", "FMLBH", "TBLJ", "CJSJ", "ZHXGSJ", "SFSC") VALUES (#{id},  #{dataCatName}, 
                                #{pid}, 'src/assets/images/树形控件1.png', now(), now(), 'F')
            """)
    void createDataCatP(String id, String dataCatName, String pid);

    @Insert("""
             INSERT INTO "LIWEIJIE"."T_SJYGL_SJML" ("MLBH", "MLMC", "FMLBH", "TBLJ", "CJSJ", "ZHXGSJ", "SFSC") VALUES (#{id}, #{dataCatName}, 
                                #{pid}, 'src/assets/images/树形控件2.png', now(), now(), 'F')
            """)
    void createDataCatC(String id, String dataCatName, String pid);

    @Update("""
                     UPDATE "LIWEIJIE"."T_SJYGL_SJML"  SET
                "MLMC" = #{dataCatName},
                "ZHXGSJ" = now()
                        WHERE "MLBH" = #{dataCatId};
            """)
    void renameDataCat(String dataCatId, String dataCatName);

    @Update("""
                     UPDATE "LIWEIJIE"."T_SJYGL_SJML"  SET
                "SFSC" = 'T',
                "ZHXGSJ" = now()
                        WHERE "MLBH" = #{dataCatId};
            """)
    void delDataCat(String dataCatId);
}
